<#assign module="gasstation"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/form.css">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
</@override>
<@override name="body">

<div class="row">
	<div class="col-xs-8">
		<ul class="nav nav-tabs">
            <li><a href="${ctx}/gasstation/list">油站管理</a></li>
            <li><a href="${ctx}/gasstation/orderList">订单汇总</a></li>
            <li class="active"><a href="${ctx}/gasstation/paymentsRecordAll">资金流水</a></li>
        </ul>
	</div>
</div>

	<div class="row">
		<div class="col-md-13">
			<div class="panel">
				<div class="panel-body">
					<form class="form-inline" id="SearchForm" method="get">
					    <div class="form-group">
			                <input class="form-control" id="gasStation" name="gasStation" placeholder="加油站名称"  type="text" value="${gasStation?if_exists}"/>
			            </div>
					    <div class="form-group">
			                <input class="form-control" id="startTime" name="startTime" placeholder="开始时间" readonly="readonly" type="text" value="${start?string('yyyy-MM-dd HH:mm')}">
			            </div>
			            <div class="form-group">
			                <input class="form-control" id="endTime" name="endTime" placeholder="结束时间" readonly="readonly" type="text" value="${end?string('yyyy-MM-dd HH:mm')}">
			            </div>
			            <div class="form-group">
			                <input type="submit" class="btn btn-default" value="查询">
			            </div>
			            <div class="form-group">
			            	<button type="button" id="export_button" class="pull-right btn btn-primary"><i class="glyphicon glyphicon-save"></i>&nbsp;导出记录</button>
						</div>
					</form>
				</div>
			</div>	
	    </div>	
    </div>
    
    <div class="row">
	   <div class="col-md-12">
	   	  <div class="panel panel-default">
				<table class="table table-hover table-striped">
					<thead>
					<tr style="font-size:14px;">
						<th>时间</th>
						<th>油站</th>
						<th>服务号</th>
						<th>单号</th>
						<th>加油/充值金额</th>
						<th>实收金额</th>
						<th>操作后余额</th>
						<th>类型</th>
						<th>操作人</th>
						<th>备注</th>
					</tr>
					</thead>
				<tbody>
					<#if (page.content)?? >
						<#assign toalRealMoney=0 />
						<#assign toaladdMoney=0 />
					  	<#list page.content as data>
							<tr>
								<td>${data.created?datetime}</td>
								<td>${data.gsName?if_exists}</td>
								<td>${data.gsServiceNo?if_exists}</td>
								<td>
									${data.orderNum?if_exists}
								</td>
								<#if (data.rcType==0)>
									<td><span style="color:#00EC00;font-weight:700;">+${data.money?if_exists}</span></td>
									<td><span style="color:#00EC00;font-weight:700;">${data.realMoney?if_exists}</span></td>
									<td><span style="color:#00EC00;font-weight:700;">${data.afterMoney?if_exists}</span></td>
								<#else>
									<#if data.realMoney??>
										<#assign toalRealMoney=toalRealMoney+data.realMoney />
									</#if>
									<#if data.money??>
										<#assign toaladdMoney=toaladdMoney+data.money />
									</#if>
									<td><span style="color:#EA0000;font-weight:700;">${data.money?if_exists}</span></td>
									<td><span style="color:#EA0000;font-weight:700;">${data.realMoney?if_exists}</span></td>
									<td><span style="color:#00EC00;font-weight:700;">${data.afterMoney?if_exists}</span></td>
								</#if>
								<td>
									${data.recordTypeStr?if_exists}
								</td>
								<td>${data.operating?if_exists}</td>
								<td style="max-width:450px;">${data.memo?if_exists}</td>
							</tr>
						</#list>
						<tr>
							<td></td>
							<td></td>
							<td></td>
							<td>合计</td>
							<td>${toaladdMoney}</td>
							<td>${toalRealMoney}</td>
							<td></td>
							<td></td>
							<td></td>
							<td style="max-width:450px;"></td>
						</tr>
					</#if>
				</tbody>
			</table>
			<#if page.totalElements??>
			<ul class="pagination pull-left pagination-sm">
				<li><a>共 ${page.totalElements} 条数据</a></li>
				<@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/gasstation/paymentsRecordAll">
					<@pg.param name="startTime" value="${start?string('yyyy-MM-dd HH:mm')}"/>
					<@pg.param name="endTime" value="${end?string('yyyy-MM-dd HH:mm')}"/>
					<@pg.param name="gasStation" value="${gasStation?if_exists}"/>
					<@pg.index>
						<@pg.first>
							<li><a href="${pageUrl}">&laquo;</a></li>
						</@pg.first>
						<@pg.prev>
							<li><a href="${pageUrl}">&lsaquo;</a></li>
						</@pg.prev>
						<@pg.pages>
							<#if  currentPageNumber == pageNumber >
								<li class="active"><a href="#">${pageNumber}</a></li>
							<#else>
								<li><a href="${pageUrl}">${pageNumber}</a></li>
							</#if>
						</@pg.pages>
						<@pg.next>
							<li><a href="${pageUrl}">&rsaquo;</a></li>
						</@pg.next>
						<@pg.last>
							<li><a href="${pageUrl}">&raquo;</a></li>
						</@pg.last>
					</@pg.index>
				</@pg.pager>
			</ul>
			</#if>
			</div>
		</div>
	</div>

</@override>
<@override name="footer">

<script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>

<script type="text/javascript">
	$(document).ready(function(){
	
		$("#startTime").datetimepicker({format: 'yyyy-mm-dd HH:ii', language: 'zh-CN', minView: 'hour', pickDate: true, pickTime: false, inputMask: false, autoclose: true });
		$("#endTime").datetimepicker({ format: 'yyyy-mm-dd HH:ii', language: 'zh-CN', minView: 'hour', pickDate: true, pickTime: false, inputMask: false, autoclose: true });
	
	
		$("#memo").keyup(function(){
			$("#leftWords").html(200-$(this).val().length);
		});
		
		
		
		$('#endTime').change(function(){
			var begin=new Date($('#startTime').val().replace(/-/g,"/"));
	    	var end=new Date($('#endTime').val().replace(/-/g,"/"));
	   		if(begin!=null&&end!=null&&begin-end>0){
  				 $('#endTime').val("");
  				 $.scojs_message("截止日期要在开始日期之后!", $.scojs_message.TYPE_ERROR);
	      	}
	 	});
	 	
		$('#startTime').change(function(){
			var begin=new Date($('#startTime').val().replace(/-/g,"/"));
		 	var end=new Date($('#endTime').val().replace(/-/g,"/"));
		 	if(begin!=null&&end!=null&&begin-end>0){
	  			$('#endTime').val("");
				 $.scojs_message("开始日期要在截止日期之前!", $.scojs_message.TYPE_ERROR);
	      	}
		});
		
		$("#export_button").click(function(){
		
			window.location="${ctx}/gasstation/paymentsRecordAllExport?startTime="
			+$("#startTime").val()+"&endTime="+$("#endTime").val()+"&gasStation="+$("#gasStation").val();
		});
	});
</script>
</@override>
<@extends name="../layout.ftl"/>